#ifndef SIMLINK_H
#define SIMLINK_H

#include <stdint.h>
#include <common/Runnable.h>
#define ORBSUBSCRIBER_WORKAROUND_NAMESPACE simlink
#include <common/orbhelper.h>
#include <uORB/uORB.h>
#include <uORB/topics/sim_sensors.h>
#include <uORB/topics/actuator_controls.h>

class SerialPort;


class SimLink : public Runnable {
public:
	SimLink(SerialPort *port);
	virtual ~SimLink();
	
private:
	SimLink();
	virtual void run();
	void update();
	int request(uint8_t *data, int datasize);
	void response(uint8_t *data, int datasize);
	void fail();

	SerialPort *port_;
	static const int bufsize_;
	uint8_t *buf_;
	static const uint8_t addr_;
	static const uint8_t id_;
	int fail_cnt_;

	orbhelper::OrbPublisher<sim_sensors_s, ORB_ID(sim_sensors)> sim_sensors_;
	orbhelper::OrbSubscriber<actuator_controls_s, ORB_ID_VEHICLE_ATTITUDE_CONTROLS> actuator_controls_;
};

#endif
